import {defHttp} from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";

const { createConfirm } = useMessage();

enum Api {
  list = '/peihebumenbiao/peihebumenbiao/list',
  save='/peihebumenbiao/peihebumenbiao/add',
  edit='/peihebumenbiao/peihebumenbiao/edit',
  receive='/peihebumenbiao/peihebumenbiao/jieshoubohui',
  deleteOne = '/peihebumenbiao/peihebumenbiao/delete',
  deleteBatch = '/peihebumenbiao/peihebumenbiao/deleteBatch',
  importExcel = '/peihebumenbiao/peihebumenbiao/importExcel',
  exportXls = '/peihebumenbiao/peihebumenbiao/exportXls',
  shenhefankuiList='/Shenhefankuibiao/shenhefankuibiao/list',
  receiveShenhefankui='/Shenhefankuibiao/shenhefankuibiao/receive',
  chuliqingkuang='/Shenhefankuibiao/shenhefankuibiao/chuliqingkuang'
}
/**
 * 导出api
 * @param params
 */
export const getExportUrl = Api.exportXls;
/**
 * 导入api
 */
export const getImportUrl = Api.importExcel;
/**
 * 列表接口
 * @param params
 */
export const list = (params) =>
  defHttp.get({url: Api.list, params});

//接收驳回
//接收任务
export const receive =(params)=>{
  return defHttp.post({url: Api.receive, params});
}

/**
 * 删除单个
 */
export const deleteOne = (params,handleSuccess) => {
  return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}

// 新增：获取配合主管列表
export const getPeiheZhuguanList = () => {
  return defHttp.get({ url: '/peihebumenbiao/peihebumenbiao/peihezhuguan' });
};

// 新增：选择配合主管
export const choosePeiheZhuguan = (params) => {
  return defHttp.post({ url: '/peihebumenbiao/peihebumenbiao/chosoepeihezhuguan', params });
};

// 新增：获取审核反馈列表
export const getShenhefankuiList = (params) => {
  return defHttp.post({ url: Api.shenhefankuiList, params });
};

// 新增：选择审核反馈
export const receiveShenhefankui = (params) => {
  return defHttp.post({ url: Api.receiveShenhefankui, params });
};

// 新增：获取处理情况列表
export const getChuliqingkuang = (params) => {
  return defHttp.post({ url: Api.chuliqingkuang, params });
}

/**
 * 批量删除
 * @param params
 */
export const batchDelete = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const saveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.edit : Api.save;
  return defHttp.post({url: url, params});
}
